package com.cems.controller;

import com.cems.mapper.EntrustMapper;
import com.cems.mapper.MessageMapper;
import com.cems.pojo.Message;
import com.cems.pojo.SysEntrust;
import com.cems.pojo.SysUser;
import com.cems.service.AdminService;
import com.cems.service.EntrustService;
import com.cems.service.UserService;
import com.cems.util.DateUtil;
import com.cems.util.RedisUtil;
import com.cems.util.ShiroMd5Util;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class MessageController {
    @Autowired
    AdminService adminService;
    @Autowired
    UserService userService;
    @Autowired
    EntrustService entrustService;
    @Autowired
    EntrustMapper entrustMapper;
    @Autowired
    MessageMapper messageMapper;

    //进入信息页面
    @RequestMapping("aaa/{id}")
    public String aaa(@PathVariable String id, Model model){
        List<Message> messages = messageMapper.selAllMessageById(Integer.valueOf(id));
        model.addAttribute("messages",messages);
       messages.forEach(System.out::println);
        return "message/SystemMessage";
    }

    //删除信息
    @GetMapping("delMessage")
    @ResponseBody
    public String del(String id){
        Message message = messageMapper.selAllMessageById2(Integer.valueOf(id));
        messageMapper.delMessage(Integer.valueOf(id));
        return String.valueOf(message.getUserId());
    }

}
